package com.github.wxiaoqi.security.auth.client.config;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import cn.hutool.setting.Setting;
import lombok.Getter;
import lombok.Setter;

@Component
public class AuthClientProperties {
	@Value("config/authClient-${spring.profiles.active}.setting")
	private String env;
	
	@Getter
	@Value("${spring.application.name}")
    private String applicationName;
	
	@Getter
	@Setter
	private byte[] pubClientKeyByte;
	
	@Getter
	@Setter
	private byte[] pubUserKeyByte;
	
	@Getter
	private String userTokenHeader;
	
	@Getter
	private String clientId;
	
	@Getter
	private String clientSecret;
	
	@Getter
	private String clientTokenHeader;
	
	@PostConstruct
	private void init() {
		Setting s = new Setting(env,true);
		userTokenHeader = s.get("user","token-header");
		clientId = s.get("client","id");
		clientSecret = s.get("client","secret");
		clientTokenHeader = s.get("client","token-header");
	}
}
